import axios from 'axios'
import message from './Message'

const service = axios.create({
  // baseURL: 'http://127.0.0.1:7001',
  timeout: 5000
})

/**
 * 请求拦截
 */
service.interceptors.request.use((config) => {
  return config
})

/**
 * 响应拦截
 */
service.interceptors.response.use((response) => {
  if (response.data.code !== 0) {
    message({
      content: response.data.msg,
      type: 'error',
      duration: 1000
    })
    return null
  }
  return response.data.data
})

export default service
